<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*, java.util.*, javax.naming.*, javax.sql.*" %>
<%@ page import="cn.edu.lingnan.service.IStudentService" %>
<%@ page import="cn.edu.lingnan.pojo.Student" %>
<%
    // 获取当前用户的ID（假设通过session获得）
    Integer studentId = (Integer) session.getAttribute("sid");
    if (studentId == null) {
        response.sendRedirect("/index.jsp");
        return;
    }

    // 获取学生信息
    IStudentService service = new IStudentService();
    Student student = service.findStudentById(studentId);
%>
<!DOCTYPE html>
<html>
<head>
    <title>个人信息</title>
    <link rel="stylesheet" type="text/css" href="/css/viewStu.css">
</head>
<body>
<div style="display: flex; align-items: center; margin-bottom: 20px;">
    <a href="/loginOut" class="link-style">注销</a>
    <a href="/main.jsp" class="link-style">返回首页</a></div>
<div class="container">
<div class="profile-container">
    <table>
        <h2>个人信息</h2>
        <tr><th>ID</th><td><%= student.getId() %></td></tr>
        <tr><th>名字</th><td><%= student.getName() %></td></tr>
        <tr><th>性别</th><td><%= student.getGender() %></td></tr>
        <tr><th>专业</th><td><%= student.getMajor() %></td></tr>
        <tr><th>班级</th><td><%= student.getClassX() %></td></tr>
        <tr><th>权限</th><td><%= student.getRight() %></td></tr>
        <tr><th>标志</th><td><%= student.getFlag() %></td></tr>
    </table>

    <h2>修改密码</h2>
    <form action="ChangePasswordServlet" method="post">
        <label for="oldPassword">旧密码：</label>
        <input type="password" id="oldPassword" name="oldPassword" required><br>
        <label for="newPassword">新密码：</label>
        <input type="password" id="newPassword" name="newPassword" required><br>
        <button type="submit">提交</button>
    </form>
</div>
</div>
</body>
</html>